<script src="js/jquery/jquery.MultiFile.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
<script type="text/javascript" src="js/jquery/jquery.form.js"></script>

<script type="text/javascript">
var afid = "<?php if(isset($_GET['id'])){ echo $_GET['id']; } ?>";
$(document).ready(function(){	
	initializeGeoCoder();
	$("#map_canvas").hide();

	jQuery.extend(jQuery.validator.messages, {
	  required: '*',
	  remote: '*'
	});
	
	/**** start add affiliate***/
	$("#informationvehicles").validate({
		errorClass: "my-error-class",
		validClass: "my-valid-class",
		debug: false,
		submitHandler: function(form){
		if( $("#vehicletype").val() ||  $("#vehiclemodel").val() ||  $("#capacity").val() || $("#vehiclenum").val()){
				var $dialog = $(
					"<div title='Add Rates'></div>"
				);
				
				$dialog.dialog({
					title: "Please Choose An Option Or Press ESC Key",
					resizable: false,
					width: 300,
					height: 50,
					autoOpen: false,
					closeOnEscape: true,
					closeText: "Close",
					modal:true,
					zIndex: 9999,
					buttons:{
						"Add Another": function(){
							if( $("#vehicletype").val()){
								$.post("query/addaffiliatevehicleinformation.php", $("#informationvehicles").serialize(), function(data){
									alert("Saved!");
									$("#addedvehicle").append($("#vehiclemodel").val() + "\n");
									cleanDiv();
								});
							}
							$( this ).dialog( "close" );
						},
						"Save and Continue": function(){
							if( $("#vehicletype").val()){
								$.post("query/addaffiliatevehicleinformation.php", $("#informationvehicles").serialize(), function(data){
									alert("Saved!");
									cleanDiv();	
									window.location.replace("panel.php?page=add_affiliate_rate&id="+afid);
								});
							}
							$(this).dialog("close");
						}
					}
				});
			
				$dialog.dialog("open");
				return false;
			}else{
				alert("Please fill up required fields *");
			}
		}
	});
	 
	
	$("#vehicletype").autocomplete({
		source: "query/getvehicletype.php",
		minLength: 2,
		change: function(event,ui){
			$("#affiliateid").val(afid);
		},
		open: function() {
			$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
		},
		close: function() {
			$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
		}
	});	
	/****** end add affiliate ****/
	
	
	$('#photoimg').live('change', function() { 
		$("#picpreview").html('');
		$("#picpreview").html('<img src="images/shared/loader.gif" alt="Uploading...."/>');
		$("#imageformvehicle").ajaxForm({
			target: '#picpreview'
		}).submit();
	});
	
	$("#btnClearVehicle").click(function(){
		$('#imageformvehicle').each(function(){
			this.reset();
		});
		$("#picpreview").empty();
		$("#addedvehicle").empty();
	});
	
	$("#btnSkip").click(function(){
		window.location.replace("panel.php?page=add_affiliate_rate&id="+afid);
	});
	
	
	function cleanDiv(){
		$('#imageformvehicle').each(function(){
			this.reset();
		});
		
		$("#picpreview").empty();
		var frm_elements =  informationvehicles.elements;
			for (i = 0; i < frm_elements.length; i++)
			{
				field_type = frm_elements[i].type.toLowerCase();
				switch (field_type)
				{
				case "text":
				case "password":
				case "hidden":
					frm_elements[i].value = "";
					break;
				case "radio":
				case "checkbox":
					if (frm_elements[i].checked)
					{
						frm_elements[i].checked = false;
					}
					break;
				case "select-one":
				case "select-multi":
					frm_elements[i].selectedIndex = -1;
					break;
				default:
					break;
				}
			}

		}
	
	
 
});
</script>


<!--  start nav-outer-repeat................................................... END -->
 
 <div class="clear"></div>
 
<!-- start content-outer -->
<div id="content-outer">
<!-- start content -->
<div id="content">

<div id="map_canvas"></div>

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
	<!--  start content-table-inner -->
	<div id="content-table-inner">
	
	<table border="0" width="100%" cellpadding="0" cellspacing="0">
	<tr valign="top">
	<td>
	
	
		<!--  start step-holder -->
		<div id="step-holder">
			<div class="step-no">1</div>
			<div class="step-light-left">Add Affiliate</div>
			<div class="step-light-right">&nbsp;</div>
			<div class="step-no">2</div>
			<div class="step-dark-left">Add Vehicle</div>
			<div class="step-dark-right">&nbsp;</div>
			<div class="step-no">3</div>
			<div class="step-light-left">Add Affiliate Rate</div>
			<div class="step-light-right">&nbsp;</div>
			<div class="step-no">4</div>
			<div class="step-light-left">Add Affiliate Driver</div>
			<div class="step-light-right">&nbsp;</div>
			<div class="step-no">5</div>
			<div class="step-light-left">Add Terms & Conditions</div>
			<div class="step-light-round">&nbsp;</div>
		</div>
		<!--  end step-holder -->
	
		<!-- start id-form -->
		<form id="informationvehicles" method="post" action="">	
		<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
			<tr>
				<th valign="top">Vehicle Detail:</th>
				<td>
					<br>
					<input type="text" name="vehicletype" id="vehicletype" class="inp-form" placeholder="Vehicle Type*" />
					&nbsp;
					<input type="text" name="vehiclemodel" id="vehiclemodel" class="inp-form" placeholder="Vehicle Model*" />
					&nbsp;
					<input type="text" name="capacity" id="capacity" class="inp-form" placeholder="Capacity*" />	
				</td>
			</tr>
			
			<tr>
				<th>Upload Image:</th>
				<td>
			
				</td>
			</tr>
			
			<tr>
				<th valign="top">Added Vehicle:</th>
				<td>
					<textarea id="addedvehicle" name="addedvehicle" rows="5" cols="30" disabled="false"></textarea>
				</td>
			</tr>

			
			<tr>
				<th valign="top">&nbsp;</th>
				<td>
				</td>
			</tr>


			<tr>
				<th>&nbsp;</th>
				<td valign="top">
					<input type="submit" class="form-submit" />
					<input type="button" id="btnSkip" value="" class="form-skip"  />
					<input type="reset" value="" id="btnClearVehicle" class="form-reset"  />
				</td>
				<td></td>
			</tr>
			<tr>
				<th valign="top">&nbsp;</th>
				<td>
				</td>
			</tr>
			<tr>
				<th valign="top">&nbsp;</th>
				<td>
				</td>
			</tr>



			
		</table>
			<br><br>
			<input type="hidden" id="affiliateid" name="affiliateid"/>
		</form>	
	<!-- end id-form  -->
		<div>
		<form id="imageformvehicle" method="post" enctype="multipart/form-data" action='query/ajaximage.php'>
			<th valign="top"></th>
			<td> <input type="hidden" name="img_type" value="vehicle"/> </td>
			<td> <input type="file" name="photoimg" id="photoimg" style="position: absolute; top: 345px; left: 210px;" /></td> 
			<td> <div id="picpreview" style="position: absolute; top: 363px; left: 630px;"> <br><br><br>image shown here.... </div>  </td>
			<td><td><td><td><td><td><td><td><td><td><td><td><td><td></td>
		</form>
		</div>
	
	
	</td>
	<td>
	<!--  start related-activities -->
	<div id="related-activities">
		
		<!--  start related-act-top -->
		<div id="related-act-top">
		<img src="images/forms/step_bar.png" width="271" height="43" alt="" />
		</div>
		<!-- end related-act-top -->
		
		<!--  start related-act-bottom -->
		<div id="related-act-bottom">
		
			<!--  start related-act-inner -->
			<div id="related-act-inner">
			
				<div class="left"><a href=""><img src="images/forms/icon_plus.gif" width="21" height="21" alt="" /></a></div>
				<div class="right">
					<h5>Adding affiliate vehicle:</h5><br>
					<ul class="greyarrow">
						<li>First, fill up vehicle type (e.g sedan, minivan etc...)</li>
						<li>Second, fill up vehicle model available from the affiliate.</li>
						<li>Third, fill up capacity and number of vehicle available.</li>
					</ul>
				</div>
				
				<div class="right" style="color:red;">
					<h5>Note:</h5>
					If vehicle does not have image to be upload just leave it and proceed. <br><br>
					If vehicle does not have vehicle model just fill it up the same as the vehicle type.
				</div>
				
				<div class="clear"></div>
			</div>
			<!-- end related-act-inner -->
			<div class="clear"></div>
		
		</div>
		<!-- end related-act-bottom -->
	
	</div>
	<!-- end related-activities -->
	
	</td>
	
</tr>
<tr>
<td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
<td></td>
</tr>
</table>
 
<div class="clear"></div>
 

</div>
<!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>



<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->


<div class="clear">&nbsp;</div>
